package com.example.spareparts.repository;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.*;
import java.util.List;
import com.example.spareparts.entity.BatchManagement;

@Mapper
public interface BatchManagementRepository {
    @Select("SELECT * FROM BatchManagement")
    List<BatchManagement> findAllBatchManagement();
    @Insert("INSERT INTO BatchManagement (spare_part_id, quantity, batch_number, entry_date, unit_price, total_price) VALUES ( #{sparepartid}, #{quantity}, #{batchNumber}, #{entryDate}, #{unitPrice}, #{totalPrice})")
    @Options(useGeneratedKeys = true, keyProperty = "batchid")
    void insertBatchManagement(BatchManagement batchManagement);
    @Update("UPDATE BatchManagement SET batch_id= #{batchid}, spare_part_id= #{sparepartid}, quantity= #{quantity}, batch_number= #{batchNumber}, entry_date= #{entryDate}, unit_price= #{unitPrice}, total_price= #{totalPrice} WHERE batch_id= #{batchid}")
    void updateBatchManagement(BatchManagement batchManagement);
    @Delete("DELETE FROM BatchManagement WHERE batch_id= #{batchid}")
    void deleteBatchManagement(Long batchid);
    @Select("SELECT * FROM BatchManagement WHERE batch_id= #{batchid}")
    BatchManagement findBatchManagementById(Long batchid);
    @Select("SELECT * FROM BatchManagement WHERE spare_part_id= #{sparepartid}")
    List<BatchManagement> findBatchManagementBySparePartId(Long sparepartid);
    @Select("SELECT * FROM BatchManagement WHERE batch_number = #{batchNumber}")
    BatchManagement findBatchManagementByBatchNumber(String batchNumber);


}
